package javacafe.action.studybbs;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javacafe.action.Action;
import javacafe.action.ActionForward;
import javacafe.dao.BoardDAO;
import javacafe.daoimpl.BoardDAOImple;
import javacafe.dto.studybbs.StudyBBSDTO;
import javacafe.dto.studybbs.StudyPostDTO;
import javacafe.service.StudyBBSService;
import javacafe.serviceimple.StudyBBSServiceImpl;

public class ListAction implements Action {

	@Override
	public ActionForward execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		ActionForward forward = null;
		forward = new ActionForward();
		forward.setTiles(false);
		
		int sbbs_no = Integer.parseInt(request.getParameter("sbbs_no"));
		
		List<StudyPostDTO> postlist= null;

		StudyBBSService service = StudyBBSServiceImpl.getInstance();
		postlist = service.getStudyPostlist(sbbs_no);
		StudyBBSDTO sbbsDto = null;
		sbbsDto = service.getStudyBBS(sbbs_no);
		
		request.setAttribute("boardtitle", sbbsDto.getSbbs_title());
		request.setAttribute("studypostlist", postlist);
		forward.setUrl("study?command=studySubmenu&study_no=" + request.getParameter("study_no"));
		
		return forward;
	}

}
